package com.sgb.businessmodule.view.widget;

import android.util.SparseBooleanArray;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.GridLayoutManager;

import com.sgb.businessmodule.R;
import com.sgb.businessmodule.databinding.PopularBusinessPopwindowBinding;
import com.sgb.businessmodule.entity.PickFilterEntity;
import com.sgb.businessmodule.view.ui.activity.BusinessOpportunityHallActivity;
import com.sgb.businessmodule.view.ui.adapter.PopularFilterAdapter;
import com.swgk.core.customview.MaxRecyclerView;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;

import java.util.ArrayList;
import java.util.List;

/*
 * 仅适用于商机大厅侧滑适用   liWei  2021/08/12
 * */
public class PopularBusinessFilterPopWindow extends BasePopWindow {

    private FilterResultClick filterResultClick;

    private BusinessOpportunityHallActivity activity;

    private TextView okView;
    private TextView reSetView;
    private MaxRecyclerView rvBusinessType1;
    private MaxRecyclerView rvBusinessType2;
    private MaxRecyclerView rvBusinessType3;
    private MaxRecyclerView rvBusinessType4;
    private MaxRecyclerView rvBusinessStyle;
    private MaxRecyclerView rvProvince;
    private MaxRecyclerView rvCity;
    private MaxRecyclerView rvSort;

    //商机分类1 adapter
    private PopularFilterAdapter businessType1Adapter;
    //商机分类2 adapter
    private PopularFilterAdapter businessType2Adapter;
    //商机分类3 adapter
    private PopularFilterAdapter businessType3Adapter;
    //商机分类4 adapter
    private PopularFilterAdapter businessType4Adapter;
    //商机类型 adapter
    private PopularFilterAdapter businessStyleAdapter;
    //省级地区 adapter
    private PopularFilterAdapter provinceAdapter;
    //市级地区 adapter
    private PopularFilterAdapter cityAdapter;
    //综合排序 adapter
    private PopularFilterAdapter sortAdapter;

    private LinearLayout linBusinessType2;
    private LinearLayout linBusinessType3;
    private LinearLayout linBusinessType4;
    private LinearLayout linCity;

    private PopularBusinessPopwindowBinding binding;

    //初始数据填充
    private PickFilterEntity all;
    //省市二级联动数据
    private List<PickFilterEntity<List<PickFilterEntity>>> addressData;
    //商机分类四级联动数据
    private List<PickFilterEntity<List<PickFilterEntity<List<PickFilterEntity<List<PickFilterEntity>>>>>>> businessTypeData;
    private List<PickFilterEntity<List<PickFilterEntity<List<PickFilterEntity>>>>> businessType2Data;
    private List<PickFilterEntity<List<PickFilterEntity>>> businessType3Data;

    //回显
    private List<PickFilterEntity> historyList = new ArrayList<>();
    //回显
    private SparseBooleanArray checkList = new SparseBooleanArray();

    private PickFilterEntity<List<PickFilterEntity>> currentHistoryFirstItem;
    private PickFilterEntity<List<PickFilterEntity>> currentFirstItem;

    private int currentPosition = 0;

    private PickFilterEntity resultBusinessType1;
    private PickFilterEntity resultBusinessType2;
    private PickFilterEntity resultBusinessType3;
    private PickFilterEntity resultBusinessType4;
    private List<PickFilterEntity> resultBusinessStyleList;
    private PickFilterEntity resultProvince;
    private List<PickFilterEntity> resultCityList;
    private List<PickFilterEntity> resultBusinessTypeList;
    private PickFilterEntity resultSort;


    private boolean flag = true;

    //保留当前分类选中的位置
    private int currentBusinessType1 = 0;
    private int currentBusinessType2 = 0;


    public PopularBusinessFilterPopWindow(BusinessOpportunityHallActivity context) {
        super(context, DIR_RIGHT);
        this.activity = context;
    }

    @Override
    protected int popLayout() {
        return R.layout.popular_business_popwindow;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        binding = (PopularBusinessPopwindowBinding) holder.getmBinding();
        okView = holder.getPop().findViewById(R.id.ok_view);
        reSetView = holder.getPop().findViewById(R.id.reset_view);

        //滚动布局
        NestedScrollView scrollView = holder.getPop().findViewById(R.id.scrollView);
        //商机分类rv
        rvBusinessType1 = holder.getPop().findViewById(R.id.rv_business_type);
        //商机分类二级类别rv
        rvBusinessType2 = holder.getPop().findViewById(R.id.rv_business_type2);
        linBusinessType2 = holder.getPop().findViewById(R.id.lin_business_type2);
        //商机分类三级类别rv
        rvBusinessType3 = holder.getPop().findViewById(R.id.rv_business_type3);
        linBusinessType3 = holder.getPop().findViewById(R.id.lin_business_type3);
        //商机分类四级类别rv
        rvBusinessType4 = holder.getPop().findViewById(R.id.rv_business_type4);
        linBusinessType4 = holder.getPop().findViewById(R.id.lin_business_type4);
        //商机类型rv
        rvBusinessStyle = holder.getPop().findViewById(R.id.rv_business_style);
        //省级地区rv
        rvProvince = holder.getPop().findViewById(R.id.rv_province);
        //市级地区rv
        rvCity = holder.getPop().findViewById(R.id.rv_city);
        linCity = holder.getPop().findViewById(R.id.lin_city);
        //综合排序
        rvSort = holder.getPop().findViewById(R.id.rv_sort);

        okView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                resultBusinessTypeList = new ArrayList<>();
                resultBusinessTypeList.add(resultBusinessType1);
                resultBusinessTypeList.add(resultBusinessType2);
                resultBusinessTypeList.add(resultBusinessType3);
                resultBusinessTypeList.add(resultBusinessType4);
                filterResultClick.result(resultBusinessTypeList, resultBusinessStyleList, resultProvince, resultCityList, resultSort);
                filterResultClick.echoStatus(currentBusinessType1, resultBusinessType1.getName(), currentBusinessType2, resultBusinessType2.getName());
                dissMiss();
            }
        });

        reSetView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                businessType1Adapter.setDefItem(0);
                linBusinessType2.setVisibility(View.GONE);
                linBusinessType3.setVisibility(View.GONE);
                linBusinessType4.setVisibility(View.GONE);
                resultBusinessType1.clearData();
                resultBusinessType2.clearData();
                resultBusinessType3.clearData();
                resultBusinessType4.clearData();

                businessStyleAdapter.resetCheckDatas();
                resultBusinessStyleList.clear();
                binding.linBusinessStyle.setVisibility(View.GONE);

                provinceAdapter.setDefItem(0);
                resultProvince.clearData();
                cityAdapter.resetCheckDatas();
                linCity.setVisibility(View.GONE);

                sortAdapter.setDefItem(0);
                resultSort.clearData();

                currentBusinessType1 = 0;
                currentBusinessType2 = 0;

                currentPosition = 0;
                resultCityList.clear();
                setAddressData(addressData, currentPosition, null);

                scrollView.scrollTo(0, 0);
            }
        });

        businessType1Adapter = new PopularFilterAdapter(mContext, R.layout.item_popular_filter, null);
        businessType1Adapter.setDefItem(0);
        businessType1Adapter.setItemSelect(true);
        rvBusinessType1.setLayoutManager(new GridLayoutManager(mContext, 3));
        rvBusinessType1.setAdapter(businessType1Adapter);
        businessType1Adapter.setOnItemClick(new AdapterOnItemClick<PickFilterEntity>() {
            @Override
            public void onItemClick(PickFilterEntity entity, int position) {
                currentBusinessType1 = position;
                if (position != 0) {
                    resultBusinessType1.replaceData(entity);
                    binding.tvBusinessType1Name.setText(entity.getName());
                } else {
                    //还原已选中数据
                    resultBusinessType1.clearData();
                    binding.tvBusinessType1Name.setText("");
                    currentBusinessType2 = 0;
                }
                if (position != 0 && businessTypeData.get(position).getChildren() != null) {
                    setBusinessType2Data(businessTypeData.get(position).getChildren());
                } else {
                    linBusinessType2.setVisibility(View.GONE);
                    linBusinessType3.setVisibility(View.GONE);
                    linBusinessType4.setVisibility(View.GONE);
                    resultBusinessType2.clearData();
                    resultBusinessType3.clearData();
                    resultBusinessType4.clearData();
                }
                if (position != 0) {
                    activity.requestBusinessStyleListData(entity.getNo());
                } else {
                    binding.linBusinessStyle.setVisibility(View.GONE);
                }
                resultBusinessStyleList.clear();
            }
        });

        businessType2Adapter = new PopularFilterAdapter(mContext, R.layout.item_popular_filter, null);
        businessType2Adapter.setDefItem(0);
        businessType2Adapter.setItemSelect(true);
        rvBusinessType2.setLayoutManager(new GridLayoutManager(mContext, 3));
        rvBusinessType2.setAdapter(businessType2Adapter);
        businessType2Adapter.setOnItemClick(new AdapterOnItemClick<PickFilterEntity>() {
            @Override
            public void onItemClick(PickFilterEntity entity, int position) {
                currentBusinessType2 = position;
                if (position != 0) {
                    resultBusinessType2.replaceData(entity);
                    binding.tvBusinessType2Name.setText(entity.getName());
                } else {
                    //还原已选中数据
                    resultBusinessType2.clearData();
                    binding.tvBusinessType2Name.setText("");
                }
                if (position != 0 && businessType2Data.get(position - 1).getChildren() != null) {
                    setBusinessType3Data(businessType2Data.get(position - 1).getChildren());
                } else {
                    linBusinessType3.setVisibility(View.GONE);
                    linBusinessType4.setVisibility(View.GONE);
                    resultBusinessType3.clearData();
                    resultBusinessType4.clearData();
                }
            }
        });

        businessType3Adapter = new PopularFilterAdapter(mContext, R.layout.item_popular_filter, null);
        businessType3Adapter.setDefItem(0);
        businessType3Adapter.setItemSelect(true);
        rvBusinessType3.setLayoutManager(new GridLayoutManager(mContext, 3));
        rvBusinessType3.setAdapter(businessType3Adapter);
        businessType3Adapter.setOnItemClick(new AdapterOnItemClick<PickFilterEntity>() {
            @Override
            public void onItemClick(PickFilterEntity entity, int position) {
                if (position != 0) {
                    resultBusinessType3.replaceData(entity);
                    binding.tvBusinessType3Name.setText(entity.getName());
                } else {
                    //还原已选中数据
                    resultBusinessType3.clearData();
                    binding.tvBusinessType3Name.setText("");
                }
                if (position != 0 && businessType3Data.get(position - 1).getChildren() != null) {
                    setBusinessType4Data(businessType3Data.get(position - 1).getChildren());
                } else {
                    linBusinessType4.setVisibility(View.GONE);
                    resultBusinessType4.clearData();
                }
            }
        });

        businessType4Adapter = new PopularFilterAdapter(mContext, R.layout.item_popular_filter, null);
        businessType4Adapter.setDefItem(0);
        businessType4Adapter.setItemSelect(true);
        rvBusinessType4.setLayoutManager(new GridLayoutManager(mContext, 3));
        rvBusinessType4.setAdapter(businessType4Adapter);
        businessType4Adapter.setOnItemClick(new AdapterOnItemClick<PickFilterEntity>() {
            @Override
            public void onItemClick(PickFilterEntity entity, int position) {
                if (position != 0) {
                    resultBusinessType4.replaceData(entity);
                    binding.tvBusinessType4Name.setText(entity.getName());
                } else {
                    binding.tvBusinessType4Name.setText("");
                    resultBusinessType4.clearData();
                }

            }
        });

        businessStyleAdapter = new PopularFilterAdapter(mContext, R.layout.item_popular_filter, null);
        businessStyleAdapter.setMultiSelect(true);
        businessStyleAdapter.setMost(Integer.MAX_VALUE);
        rvBusinessStyle.setLayoutManager(new GridLayoutManager(mContext, 3));
        rvBusinessStyle.setAdapter(businessStyleAdapter);
        businessStyleAdapter.setOnItemMultiClick(new BaseRecycleAdapter.OnItemMultiClick<PickFilterEntity>() {
            @Override
            public void onItemMultiClick(List<PickFilterEntity> pickFilterEntities, int position) {
                resultBusinessStyleList.clear();
                resultBusinessStyleList.addAll(pickFilterEntities);
                if (pickFilterEntities.size() > 0) {
                    StringBuilder builder = new StringBuilder();
                    for (PickFilterEntity entity : pickFilterEntities) {
                        builder.append(entity.getName()).append(",");
                    }
                    binding.tvBusinessStyleName.setText(builder.substring(0, builder.length() - 1));
                } else {
                    binding.tvBusinessStyleName.setText("");
                }
            }
        });

        provinceAdapter = new PopularFilterAdapter(mContext, R.layout.item_popular_filter, null);
        provinceAdapter.setDefItem(0);
        provinceAdapter.setItemSelect(true);
        rvProvince.setLayoutManager(new GridLayoutManager(mContext, 3));
        rvProvince.setAdapter(provinceAdapter);
        provinceAdapter.setOnItemClick(new AdapterOnItemClick<PickFilterEntity>() {
            @Override
            public void onItemClick(PickFilterEntity entity, int position) {
                if (position == 0) {
                    cityAdapter.clearDatas();
                    resultProvince.clearData();
                    linCity.setVisibility(View.GONE);
                    binding.tvAddressProvinceName.setText("");
                    binding.tvAddressCityName.setText("");
                    return;
                }
                resultProvince.replaceData(entity);
                binding.tvAddressProvinceName.setText(entity.getName());
                setCityData(addressData.get(position).getChildren());
            }
        });

        cityAdapter = new PopularFilterAdapter(mContext, R.layout.item_popular_filter, null);
        cityAdapter.setMultiSelect(true);
        cityAdapter.setMost(Integer.MAX_VALUE);
        rvCity.setLayoutManager(new GridLayoutManager(mContext, 3));
        rvCity.setAdapter(cityAdapter);
        cityAdapter.setOnItemMultiClick(new BaseRecycleAdapter.OnItemMultiClick<PickFilterEntity>() {
            @Override
            public void onItemMultiClick(List<PickFilterEntity> pickFilterEntities, int position) {
                if (position == 0) {
                    resultCityList.clear();
                    cityAdapter.resetCheckDatas();
                    cityAdapter.checkDatas(0);
                    flag = true;
                    binding.tvAddressCityName.setText("");
                } else {
                    if (flag) {
                        cityAdapter.resetCheckDatas();
                        cityAdapter.checkDatas(position);
                        flag = false;
                    }
                    resultCityList.clear();
                    resultCityList.addAll(pickFilterEntities);
                    if (pickFilterEntities.size() > 0) {
                        StringBuilder builder = new StringBuilder();
                        for (PickFilterEntity entity : pickFilterEntities) {
                            builder.append(entity.getName()).append(",");
                        }
                        binding.tvAddressCityName.setText(builder.substring(0, builder.length() - 1));
                    }
                }
            }
        });

        sortAdapter = new PopularFilterAdapter(mContext, R.layout.item_popular_filter, null);
        sortAdapter.setDefItem(0);
        sortAdapter.setItemSelect(true);
        rvSort.setLayoutManager(new GridLayoutManager(mContext, 3));
        rvSort.setAdapter(sortAdapter);
        sortAdapter.setOnItemClick(new AdapterOnItemClick<PickFilterEntity>() {
            @Override
            public void onItemClick(PickFilterEntity entity, int position) {
                resultSort.replaceData(entity);
            }
        });

        all = new PickFilterEntity();
        all.setNo("");
        all.setName("全部");

        resultBusinessType1 = new PickFilterEntity();
        resultBusinessType2 = new PickFilterEntity();
        resultBusinessType3 = new PickFilterEntity();
        resultBusinessType4 = new PickFilterEntity();
        resultBusinessStyleList = new ArrayList<>();
        resultProvince = new PickFilterEntity();
        resultCityList = new ArrayList<>();
        resultBusinessTypeList = new ArrayList<>();
        resultSort = new PickFilterEntity();

        setSortData(getSortData());
    }

    /**
     * @param data 商机分类四级联动数据
     */
    public void setBusinessTypeData(List<PickFilterEntity<List<PickFilterEntity<List<PickFilterEntity<List<PickFilterEntity>>>>>>> data) {
        if (businessTypeData == null) {
            businessTypeData = new ArrayList<>();
        }
        //移除查看更多数据
        data.remove(data.size() - 1);
        businessTypeData.clear();
        businessTypeData.addAll(data);
        List<PickFilterEntity> list = new ArrayList<>();
        for (PickFilterEntity pickFilterEntity : data) {
            PickFilterEntity entity = new PickFilterEntity();
            entity.setNo(pickFilterEntity.getNo());
            entity.setName(pickFilterEntity.getName());
            list.add(entity);
        }
        //商机分类一级类目列表
        businessType1Adapter.setDatas(list);
        businessType1Adapter.setDefItem(0);
    }

    /**
     * @param data 商机分类二级类目列表
     */
    public void setBusinessType2Data(List<PickFilterEntity<List<PickFilterEntity<List<PickFilterEntity>>>>> data) {
        linBusinessType2.setVisibility(View.VISIBLE);
        linBusinessType3.setVisibility(View.GONE);
        linBusinessType4.setVisibility(View.GONE);
        if (businessType2Data == null) {
            businessType2Data = new ArrayList<>();
        }
        businessType2Data.clear();
        businessType2Data.addAll(data);
        List<PickFilterEntity> list = new ArrayList<>();
        for (PickFilterEntity pickFilterEntity : data) {
            PickFilterEntity entity = new PickFilterEntity();
            entity.setNo(pickFilterEntity.getNo());
            entity.setName(pickFilterEntity.getName());
            list.add(entity);
        }
        if (data.size() >= 1 && !list.get(0).getName().equals("全部")) {
            list.add(0, all);
        }
        businessType2Adapter.clearDatas();
        businessType2Adapter.setDatas(list);
        businessType2Adapter.setDefItem(0);
    }

    /**
     * @param data 商机分类三级类目列表
     */
    public void setBusinessType3Data(List<PickFilterEntity<List<PickFilterEntity>>> data) {
        linBusinessType3.setVisibility(View.VISIBLE);
        linBusinessType4.setVisibility(View.GONE);
        if (businessType3Data == null) {
            businessType3Data = new ArrayList<>();
        }
        businessType3Data.clear();
        businessType3Data.addAll(data);
        List<PickFilterEntity> list = new ArrayList<>();
        for (PickFilterEntity pickFilterEntity : data) {
            PickFilterEntity entity = new PickFilterEntity();
            entity.setNo(pickFilterEntity.getNo());
            entity.setName(pickFilterEntity.getName());
            list.add(entity);
        }
        if (data.size() >= 1 && !list.get(0).getName().equals("全部")) {
            list.add(0, all);
        }
        businessType3Adapter.clearDatas();
        businessType3Adapter.setDatas(list);
        businessType3Adapter.setDefItem(0);
    }

    /**
     * @param data 商机分类四级类目列表
     */
    public void setBusinessType4Data(List<PickFilterEntity> data) {
        linBusinessType4.setVisibility(View.VISIBLE);
        if (data.size() >= 1 && !data.get(0).getName().equals("全部")) {
            data.add(0, all);
        }
        businessType4Adapter.clearDatas();
        businessType4Adapter.setDatas(data);
        businessType4Adapter.setDefItem(0);
    }

    /**
     * @param data 商机类型数据
     */
    public void setBusinessStyleData(List<PickFilterEntity> data) {
        binding.linBusinessStyle.setVisibility(View.VISIBLE);
        businessStyleAdapter.setDatas(data);
        businessStyleAdapter.checkALLDatas();
        //businessStyleAdapter.setCheckDefault(-1);
        resultBusinessStyleList.clear();
        resultBusinessStyleList.addAll(data);
        if (data.size() > 0) {
            StringBuilder builder = new StringBuilder();
            for (PickFilterEntity entity : data) {
                builder.append(entity.getName()).append(",");
            }
            binding.tvBusinessStyleName.setText(builder.substring(0, builder.length() - 1));
        }
    }

    /**
     * @param data 省市二级联动数据
     */
    public void setAddressData(List<PickFilterEntity<List<PickFilterEntity>>> data, int position, List<PickFilterEntity> secondList) {
        if (addressData == null) {
            addressData = new ArrayList<>();
            addressData.add(all);

            for (PickFilterEntity<List<PickFilterEntity>> entity : data) {
                PickFilterEntity<List<PickFilterEntity>> entityNew = new PickFilterEntity<>();
                entityNew.setNo(entity.getNo());
                entityNew.setName(entity.getName());
                List<PickFilterEntity> entityList = new ArrayList<>();
                entityList.add(all);
                for (PickFilterEntity entity1 : entity.getChildren()) {
                    PickFilterEntity entity2 = new PickFilterEntity();
                    entity2.setNo(entity1.getNo());
                    entity2.setName(entity1.getName());
                    entity2.setChildren(entity1.getChildren());
                    entityList.add(entity2);
                }
                entityNew.setChildren(entityList);
                addressData.add(entityNew);
            }
            //获取省份列表数据
            List<PickFilterEntity> entityList = new ArrayList<>();
            for (PickFilterEntity entity : addressData) {
                PickFilterEntity entity2 = new PickFilterEntity();
                entity2.setNo(entity.getNo());
                entity2.setName(entity.getName());
                entityList.add(entity2);
            }

            //填充省市列表
            provinceAdapter.setDatas(entityList);
            provinceAdapter.setDefItem(currentPosition);
        }

        if (position != -1){
            currentPosition = position;
            provinceAdapter.setDefItem(currentPosition);
        }

        setEchoData(secondList);
    }

    /**
     * 数据回显
     *
     * @param secondList
     */
    public void setEchoData(List<PickFilterEntity> secondList) {
        if (secondList != null && !secondList.isEmpty()) {
            historyList.clear();
            historyList.addAll(secondList);
            for (PickFilterEntity<List<PickFilterEntity>> item : addressData) {
                if (item.getChildren() != null && item.getChildren().contains(secondList.get(0))) {
                    currentHistoryFirstItem = item;
                    currentPosition = addressData.indexOf(item);
                    break;
                }
            }
        }

        currentFirstItem = addressData.get(currentPosition);
        provinceAdapter.setDefItem(currentPosition);
        setCityData(addressData.get(currentPosition).getChildren());
    }

    /**
     * 设置市级区域列表
     *
     * @param list 市级列表数据
     */
    public void setCityData(List<PickFilterEntity> list) {
        if (list == null) {
            cityAdapter.resetCheckDatas();
            cityAdapter.clearDatas();
            linCity.setVisibility(View.GONE);
            return;
        }
        linCity.setVisibility(View.VISIBLE);
        cityAdapter.setDatas(list);
        if (currentHistoryFirstItem != null) {
            if (currentHistoryFirstItem.equals(currentFirstItem)) {
                if (!historyList.isEmpty()) {
                    for (PickFilterEntity entity : list) {
                        if (historyList.contains(entity)) {
                            checkList.put(list.indexOf(entity), true);
                        } else {
                            checkList.put(list.indexOf(entity), false);
                        }
                    }
                    flag = false;
                    cityAdapter.setCheckDefultDatas(historyList, checkList);
                }
                currentHistoryFirstItem = null;
            }
        } else {
            flag = true;
            cityAdapter.resetCheckDatas();
            cityAdapter.setCheckDefault(0);
        }
    }

    /**
     * @param data 综合排序列表数据
     */
    public void setSortData(List<PickFilterEntity> data) {
        sortAdapter.clearDatas();
        sortAdapter.resetCheckDatas();
        sortAdapter.setDatas(data);
        sortAdapter.setDefItem(0);
        resultSort.setNo("1");
    }

    /**
     * 传递商机分类联动数据位置
     *
     * @param currentIndex      当前商机分类的选中位置
     * @param currentChildIndex 当前商机二级分类选中位置
     */
    public void setIndex(int currentIndex, int currentChildIndex) {
        currentBusinessType1 = currentIndex;
        currentBusinessType2 = currentChildIndex;
        businessType1Adapter.setDefItem(currentIndex);
        if (currentIndex != 0) {
            if (!businessTypeData.get(currentIndex).getNo().equals(resultBusinessType1.getNo())) {
                activity.requestBusinessStyleListData(businessTypeData.get(currentIndex).getNo());
            }
            resultBusinessType1.replaceData(businessTypeData.get(currentIndex));
            if (businessTypeData.get(currentIndex).getChildren() != null) {
                setBusinessType2Data(businessTypeData.get(currentIndex).getChildren());
                businessType2Adapter.setDefItem(currentChildIndex);
                if (currentChildIndex != 0) {
                    resultBusinessType2.replaceData(businessTypeData.get(currentIndex).getChildren().get(currentChildIndex));
                    if (businessTypeData.get(currentIndex).getChildren().get(currentChildIndex).getChildren() != null) {
                        setBusinessType3Data(businessTypeData.get(currentIndex).getChildren().get(currentChildIndex).getChildren());
                    }
                }
            }
        }
    }

    public interface FilterResultClick {

        void result(List<PickFilterEntity> a, List<PickFilterEntity> b, PickFilterEntity c, List<PickFilterEntity> d, PickFilterEntity e);

        void echoStatus(int a, String nameA, int b, String nameB);
    }

    public void setFilterResultClick(FilterResultClick filterResultClick) {
        this.filterResultClick = filterResultClick;
    }

    /*
     * 综合排序数据拼装
     * */
    public List<PickFilterEntity> getSortData() {
        List<PickFilterEntity> data = new ArrayList<>();
        data.add(new PickFilterEntity("1", "发布最近"));
        data.add(new PickFilterEntity("2", "发布最早"));
        data.add(new PickFilterEntity("3", "金额小到大"));
        data.add(new PickFilterEntity("4", "金额大到小"));
        data.add(new PickFilterEntity("5", "截止最近"));
        data.add(new PickFilterEntity("6", "截止最远"));
        return data;
    }
}
